// 判断是否是数字方法
function checkNumber($s){
    return !isNaN(Number(str)) ? true : false;
}

// 发送短信验证码按钮方法
function sendCodeBtn(idDom, time){
    time = time ? parseInt(time) : 60;
    let sendBtn = document.getElementById(idDom);
    sendBtn.addEventListener('click', function() {
        sendBtn.disabled = true;let fix = '';
        let timer = setInterval(function() {
            if (time == 0) {
                clearInterval(timer);
                sendBtn.disabled = false;
                sendBtn.innerHTML = '获取验证码';
                time = 10;
            } else {
                fix = time < 10 ? '0' : '';
                sendBtn.innerHTML = fix+time + '秒后重发';
                time--;
            }
        }, 1000);
    });
}

/**
 * 获得cookie
 * @param cname
 * @returns {string}
 */
function getJsCookie(cname) {
    let name = cname + "=";
    let ca = document.cookie.split(";");
    for (let i = 0; i < ca.length; i++) {
        let c = ca[i].trim();
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
}